package com.CI.SearchCourse.Commands
{
	import com.CI.SearchCourse.Business.SearchDelegate;
	import com.CI.SearchCourse.Control.SearchDirectEvent;
	import com.CI.SearchCourse.Control.SearchOnlineEvent;
	
	import com.adobe.cairngorm.business.Responder;
	import com.adobe.cairngorm.commands.Command;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	public class SearchCommands implements Command,Responder
	{
		public function execute(event : CairngormEvent) : void
		{
			var str : String = event.type;
			
			if(str == 'searchDirect')
			{
				var directEvent : SearchDirectEvent =  SearchDirectEvent(event);
				getDelegate.sendObject(directEvent.direct); 
			}
			else
			{
				var onlineEvent : SearchOnlineEvent =  SearchOnlineEvent(event);
				getDelegate.sendObject(onlineEvent.online);
			}
		}
		
		public function onFault(event : *=null) : void
		{
			
		}
		
		public function onResult(event : *=null) : void
		{
			
		}
		
		protected function get getDelegate(): SearchDelegate
		{
			return new SearchDelegate(this);
		}
	}
}